<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :rules="rules"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="学年名称" prop="yearId">
        <el-select
          v-model="queryParams.yearId"
          placeholder="请选择学年"
          clearable
          @change="handleYear()"
          size="small"
          style="width: 240px"
        >

          <el-option
            v-for="item in statusOptions"
            :key="item.index"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item> -->

      <el-form-item label="学院名称" prop="collegeId">
        <el-select
          v-model="queryParams.collegeId"
          @change="handleCollege"
          placeholder="请选择学院"
          clearable
          size="small"
          style="width: 240px"
        >
          <!--这里要处理学年信息,给一个接口自动获取专业信息，然后点击传参的时候自动选择显示啥-->
          <el-option
            v-for="item in statusOptions2"
            :key="item.index"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="专业名称" prop="majorId">
        <el-select
          v-model="queryParams.majorId"
          placeholder="请选择专业"
          @change="handleMajor()"
          clearable
          size="small"
          style="width: 240px"
        >
          <!--这里要处理学年信息,给一个接口自动获取学年信息，然后点击传参的时候自动选择显示啥-->
          <el-option
            v-for="item in statusOptions3"
            :key="item.index"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="班级名称" prop="classesId">
        <el-select
          v-model="queryParams.classesId"
          placeholder="请选择班级"
          clearable
          size="small"
          style="width: 240px"
        >
          <!--这里要处理学年信息,给一个接口自动获取学年信息，然后点击传参的时候自动选择显示啥-->
          <el-option
            v-for="item in statusOptions4"
            :key="item.index"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="学号" prop="xh">
        <el-input
          v-model="queryParams.xh"
          placeholder="请输入学号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="xm">
        <el-input
          v-model="queryParams.xm"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="姓名拼音" prop="xmpy">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.xmpy"-->
      <!--          placeholder="请输入姓名拼音"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="曾用名" prop="cym">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.cym"-->
      <!--          placeholder="请输入曾用名"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="院系所部中心号" prop="yxsh">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.yxsh"-->
      <!--          placeholder="请输入院系所部中心号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="专业号" prop="zyh">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.zyh"-->
      <!--          placeholder="请输入专业号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="专业科类码" prop="zyklm">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.zyklm"-->
      <!--          placeholder="请输入专业科类码"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="培养方式码" prop="pyfsm">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.pyfsm"-->
      <!--          placeholder="请输入培养方式码"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="学生类别码" prop="xslbm">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.xslbm"-->
      <!--          placeholder="请输入学生类别码"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="研究方向码" prop="yjfxm">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.yjfxm"-->
      <!--          placeholder="请输入研究方向码"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="导师职工号" prop="dszgh">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.dszgh"-->
      <!--          placeholder="请输入导师职工号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="获得学历方式码" prop="hdxlfsm">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.hdxlfsm"-->
      <!--          placeholder="请输入获得学历方式码"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="学分制学生状况" prop="xfzxszk">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.xfzxszk"-->
      <!--          placeholder="请输入学分制学生状况"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!-- <el-form-item label="学制" prop="xz">
        <el-input
          v-model="queryParams.xz"
          placeholder="请输入学制"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入学年月" prop="rxny">
        <el-input
          v-model="queryParams.rxny"
          placeholder="请输入入学年月"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="年级" prop="nj">
        <el-input
          v-model="queryParams.nj"
          placeholder="请输入年级"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="班号" prop="bh">
        <el-input
          v-model="queryParams.bh"
          placeholder="请输入班号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号" prop="sfzh">
        <el-input
          v-model="queryParams.sfzh"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别码" prop="xbm">
        <el-select
          v-model="queryParams.xbm"
          placeholder="请选择性别码"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in xbmOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="血型码" prop="xxm">
        <el-input
          v-model="queryParams.xxm"
          placeholder="请输入血型码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期" prop="csrq">
        <el-date-picker
          v-model="queryParams.csrq"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="请输入出生日期"
          style="width: 100%"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        >
        </el-date-picker> -->

      <!-- <el-input
          v-model="queryParams.csrq"
          placeholder="请输入出生日期"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
      <!-- </el-form-item>
      <el-form-item label="联系电话" prop="lxdh">
        <el-input
          v-model="queryParams.lxdh"
          placeholder="请输入联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:student:add']"
        >新增</el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:student:edit']"
        >选择</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button v-show="!flag" type="primary" plain size="mini" @click="handleaddGroup"
          >批量导入</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:student:export']"
        >导出</el-button>
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="studentList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!--      <el-table-column label="主键id" align="center" prop="id" />-->
      <el-table-column label="学号" align="center" prop="xh" />
      <el-table-column label="姓名" align="center" prop="xm" />
      <!-- <el-table-column label="姓名拼音" align="center" prop="xmpy" /> -->
      <!-- <el-table-column label="曾用名" align="center" prop="cym" /> -->
      <!-- <el-table-column label="院系所部中心号" align="center" prop="yxsh" /> -->
      <!-- <el-table-column label="专业号" align="center" prop="zyh" /> -->
      <!-- <el-table-column label="专业科类码" align="center" prop="zyklm" /> -->
      <!-- <el-table-column label="培养方式码" align="center" prop="pyfsm" /> -->
      <!-- <el-table-column label="学生类别码" align="center" prop="xslbm" /> -->
      <!-- <el-table-column label="研究方向码" align="center" prop="yjfxm" /> -->
      <!-- <el-table-column label="导师职工号" align="center" prop="dszgh" /> -->
      <!-- <el-table-column label="获得学历方式码" align="center" prop="hdxlfsm" /> -->
      <!-- <el-table-column label="学分制学生状况" align="center" prop="xfzxszk" /> -->
      <el-table-column label="学制" align="center" prop="xz" />
      <el-table-column label="入学年月" align="center" prop="rxny" />
      <!-- <el-table-column label="年级" align="center" prop="nj" /> -->
      <el-table-column label="班号" align="center" prop="bh" />
      <el-table-column label="身份证号" align="center" prop="sfzh" />
      <el-table-column
        label="性别码"
        align="center"
        prop="xbm"
        :formatter="xbmFormat"
      />
      <!-- <el-table-column label="血型码" align="center" prop="xxm" /> -->
      <el-table-column label="出生日期" align="center" prop="csrq" />
      <!-- <el-table-column label="出生地码" align="center" prop="csdm" /> -->
      <!-- <el-table-column label="籍贯码" align="center" prop="jgm" /> -->
      <!-- <el-table-column label="民族码" align="center" prop="mzm" /> -->
      <!-- <el-table-column label="宗教信仰" align="center" prop="zjxy" />
      <el-table-column label="港澳台侨码" align="center" prop="gatqm" />
      <el-table-column label="健康状况码" align="center" prop="jkzkm" />
      <el-table-column label="婚姻状况码" align="center" prop="hyzkm" />
      <el-table-column label="现住址" align="center" prop="xzz" />
      <el-table-column label="户口所在地" align="center" prop="hkszd" />
      <el-table-column label="户口性质码" align="center" prop="hkxzm" />
      <el-table-column label="国别码" align="center" prop="gbm" />
      <el-table-column label="特长" align="center" prop="tc" />
      <el-table-column label="联系电话" align="center" prop="lxdh" />
      <el-table-column label="通信地址" align="center" prop="txdh" />
      <el-table-column label="邮政编码" align="center" prop="yzbm" />
      <el-table-column label="电子信箱" align="center" prop="dzxx" />
      <el-table-column label="主页地址" align="center" prop="zydz" /> -->
      <el-table-column
        label="操作"
        width="150px"
        align="center"
        fixed="right"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            >选择</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:student:remove']"
          >删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <!-- <el-form-item label="学年名称" prop="yearId">
          <el-select
            v-model="form.yearId"
            placeholder="请选择学年"
            clearable
            @change="addhandleYear()"
            size="small"
            style="width: 240px"
          >

            <el-option
              v-for="item in statusOptions"
              :key="item.index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item> -->
        <el-form-item label="学院名称" prop="collegeId">
          <el-select
            v-model="form.collegeId"
            placeholder="请选择学院"
            @change="addhandleCollege"
            clearable
            size="small"
            style="width: 240px"
          >
            <!--这里要处理学年信息,给一个接口自动获取专业信息，然后点击传参的时候自动选择显示啥-->
            <el-option
              v-for="item in statusOptions2"
              :key="item.index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="专业名称" prop="majorId">
          <el-select
            v-model="form.majorId"
            placeholder="请选择专业"
            clearable
            @change="addhandlemajor()"
            size="small"
            style="width: 240px"
          >
            <!--这里要处理学年信息,给一个接口自动获取学年信息，然后点击传参的时候自动选择显示啥-->
            <el-option
              v-for="item in statusOptions3"
              :key="item.index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="班级名称" prop="classesId">
          <el-select
            v-model="form.classesId"
            placeholder="请选择班级"
            clearable
            size="small"
            style="width: 240px"
          >
            <!--这里要处理学年信息,给一个接口自动获取学年信息，然后点击传参的时候自动选择显示啥-->
            <el-option
              v-for="item in statusOptions4"
              :key="item.index"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="addSubmit">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listCollege,
  listYear,
  listStudent,
  getStudent,
  delStudent,
  addStudent,
  updateStudent,
  exportStudent,
} from "@/api/system/student";
import {
  listExaminee,
  getExaminee,
  delExaminee,
  addExaminee,
  addExamineeTemporary,
  updateExaminee,
  exportExaminee,
} from "@/api/exam/examinee";
import {
  listSchoolyear,
  getSchoolyear,
  delSchoolyear,
  addSchoolyear,
  updateSchoolyear,
  exportSchoolyear,
} from "@/api/org/schoolyear";
import { listMajor } from "@/api/org/major";
import { listClasses } from "@/api/org/classes";
import { validateStudentID } from "@/utils/formCheck";
export default {
  name: "searchstudent",
  props: ["row","flag"],
  data() {
    return {
      //学年信息
      // statusOptions: [],
      //学院信息
      statusOptions2: [],
      //专业信息
      statusOptions3: [],
      //班级信息
      statusOptions4: [],
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生信息表格数据
      studentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 性别码字典
      xbmOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        yearId: "",
        xh: null,
        xm: null,
        xmpy: null,
        cym: null,
        yxsh: null,
        zyh: null,
        zyklm: null,
        pyfsm: null,
        xslbm: null,
        yjfxm: null,
        dszgh: null,
        hdxlfsm: null,
        xfzxszk: null,
        xz: null,
        rxny: null,
        nj: null,
        bh: null,
        sfzh: null,
        xbm: null,
        xxm: null,
        csrq: null,
        csdm: null,
        jgm: null,
        mzm: null,
        zjxy: null,
        gatqm: null,
        jkzkm: null,
        hyzkm: null,
        xzz: null,
        hkszd: null,
        hkxzm: null,
        gbm: null,
        tc: null,
        lxdh: null,
        txdh: null,
        yzbm: null,
        dzxx: null,
        zydz: null,
        classesId: "",
      },
      //引用考生列表
      list_examinee: [],
      // 表单参数
      form: {
        schoolYear: "",
        collegeId: "",
        majorId: "",
        classesId: "",
      },
      // 表单校验
      rules: {
        xh: [
          { required: true, message: "学号不能为空", trigger: "blur" },
          { validator: validateStudentID, trigger: "blur" },
        ],
      },
    };
  },
  created() {
    console.log(11111, this.row);
    this.getList();
    this.getAllList();
    this.getDicts("sys_sex").then((response) => {
      this.xbmOptions = response.data;
    });
    this.getListExaminee();
  },
  methods: {
    //获取已引用考生列表信息（根据考试、场次调用listExaminee接口获取）
    getListExaminee() {
      listExaminee(this.row).then((response) => {
        //console.log(2222, response);
        this.list_examinee = response.rows;
      });
    },
    // 获取学年，学院，专业，班级下拉选项数据
    getAllList() {
      // listClasses().then(response => {
      //   console.log(response)
      //   this.statusOptions4 = response.data;
      // });
      // listMajor().then(response => {
      //   console.log(response)
      //   this.statusOptions3= response.data;
      // });
      // listCollege().then(response => {
      //   console.log(response)
      //   this.statusOptions2= response.data;
      // });
      // listYear().then(response => {
      //   console.log(response)
      //   this.statusOptions = response.data;
      // });
      // this.getListYear();
      this.getListCollege();
      // this.handleYear();
    },
    /** 选择学年发生改变 */
    // handleYear() {
    //   const data = { yearId: this.queryParams.yearId };
    //   listCollege(data).then((response) => {
    //     this.statusOptions2 = response;
    //   });
    // },
    //学院改变专业跟着改变
    handleCollege(val) {
      this.statusOptions3 = [];
      this.statusOptions4 = [];
      this.queryParams.majorId = '';
      this.queryParams.classesId = '';
      this.queryParams.collegeId = val;
      listMajor({
        collegeId: val,
      }).then((response) => {
        this.statusOptions3 = response.rows;
      });
    },
    //专业改变班级跟着改变
    handleMajor() {
      this.queryParams.classesId = '';
      const data = {
        collegeId: this.queryParams.collegeId,
        majorId: this.queryParams.majorId,
      };

      this.statusOptions4 = [];

      listClasses(data).then((response) => {
        this.statusOptions4 = response.rows;
      });
    },
    /** 查询学生信息列表 */
    getList() {
      this.loading = true;
      listStudent(this.queryParams).then((response) => {
        this.studentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // // 获取学年列表
    // getListYear() {
    //   listSchoolyear().then((response) => {
    //     this.statusOptions = response.rows;
    //   });
    // },
    getListCollege() {
      const data = { yearId: null };
      listCollege(data).then((response) => {
        this.statusOptions2 = response;
      });
    },
    /** 选择学年发生改变 */
    // addhandleYear() {
    //   const data = { yearId: this.queryParams.yearId };
    //   listCollege(data).then((response) => {
    //     this.statusOptions2 = response;
    //   });
    // },

    //学院改变专业跟着改变
    addhandleCollege(val) {
      this.queryParams.majorId = "";
      this.form.majorId = "";
      this.form.classesId = "";
      this.queryParams.collegeId = val;
      listMajor({
        collegeId: val,
      }).then((response) => {
        this.statusOptions3 = response.rows;
      });
    },
    //专业变班级变
    addhandlemajor() {
      this.queryParams.classesId = "";
      const data = {
        collegeId: this.queryParams.collegeId,
        majorId: this.queryParams.majorId,
      };
      listClasses(data).then((response) => {
        this.statusOptions4 = response.rows;
      });
    },
    xbmFormat(row, column) {
      return this.selectDictLabel(this.xbmOptions, row.xbm);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        classesId: null,
        userId: null,
        xh: null,
        xm: null,
        xmpy: null,
        cym: null,
        yxsh: null,
        zyh: null,
        zyklm: null,
        pyfsm: null,
        xslbm: null,
        yjfxm: null,
        dszgh: null,
        hdxlfsm: null,
        xfzxszk: null,
        xz: null,
        rxny: null,
        nj: null,
        bh: null,
        sfzh: null,
        xbm: null,
        xxm: null,
        csrq: null,
        csdm: null,
        jgm: null,
        mzm: null,
        zjxy: null,
        gatqm: null,
        jkzkm: null,
        hyzkm: null,
        xzz: null,
        hkszd: null,
        hkxzm: null,
        gbm: null,
        tc: null,
        lxdh: null,
        txdh: null,
        yzbm: null,
        dzxx: null,
        zydz: null,
        zp: null,
      };
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学生信息";
    },
    /** 引入单个学生按钮操作 */
    handleUpdate(row) {
      let that = this;
      let data={};
       if(this.flag===0){
         //es6新增的块级作用域，在块级作用域中定义的变量只能在块级中使用
          data = {
            userId: row.userId,
            examinationId: this.row.examinationId,
            sessionId: this.row.sessionId,
          };
          // console.log("flag: ",this.flag);
       }else if(this.flag===1){
          data = {
            userId: row.userId,
            examId: this.row.examinationId,
            sessionId: this.row.sessionId,
          };

          // console.log("flag: ",this.flag);
       }



      this.$confirm(
        '是否确认引入学生信息编号为"' + data.userId + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          //在引用之前判断数据项是否重复引用并过滤
          let exit = 0;
          that.getListExaminee(); //每次循环之前更新已引用考生列表
          setTimeout(() => {
            //设置时间延迟，防止因网络问题导致可以重复引入两条相同数据（*并发*）
            for (var i = 0; i < that.list_examinee.length; i++) {
              //console.log(data.userId, that.list_examinee[i].userId);
              if (data.userId == that.list_examinee[i].userId) {
                exit = 1;
              }
            }
            if (exit == 1) {
              that.$message.error("该条数据已重复引用！");
            } else {
              that.myaddExaminee(data);
            }
          }, 1000);
        })
        .catch(() => {});
    },
    myaddExaminee(data) {
      if(this.flag===0){
        addExaminee(data).then((response) => {
          this.msgSuccess("引入成功");
        });
      }else if(this.flag===1){
         addExamineeTemporary(data).then((response) => {
          this.msgSuccess("引入成功");
        });
      }


      this.open = false;
      this.form = {
        schoolYear: "",
        collegeId: "",
        majorId: "",
        classesId: "",
      };

      this.statusOptions2 = [];
      this.statusOptions3 = [];
      this.statusOptions4 = [];
    },
    //批量导入
    handleaddGroup() {
      this.title = "按班级导入";
      //专业信息
      this.statusOptions3 = [];
      this.statusOptions4 = [];
      this.open = true;
    },
    //批量导入确定
    addSubmit() {
      const data = {
        classesId: this.form.classesId,
        examinationId: this.row.examinationId,
        sessionId: this.row.sessionId,
      };
      let that = this;

      this.$confirm(
        '是否确认引入班级信息编号为"' + data.classesId + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          that.myaddExaminee(data);
        })
        .catch(() => {});
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateStudent(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除学生信息编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delStudent(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有学生信息数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.exportLoading = true;
          return exportStudent(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {});
    },
  },
};
</script>
